package org.voidness.squaretilesframework.savers;

import org.voidness.oje2d.Utils;
import org.voidness.squaretilesframework.Map;

/** A general map saver */
public class MapSaver {
    /** An old (obsolete) map format */
    public static final int OLD_FORMAT = 0;

    /** The current map format */
    public static final int SIMPLE_FORMAT = 1;

    /** An eventual xml map format wouldn't hurt */
    public static final int XML_FORMAT = 2;

    /** The line break */
    public static final String LINEBREAK = "\r\n";

    /**
     * A static method to save a map of a given format to a file.
     * 
     * @param mMap The map to save
     * @param mFilename The filename where to save the map
     * @param mFormat The format of the map
     */
    public static void save(Map mMap, String mFilename, int mFormat) {
        // Check which format we want and use the appropriate loader
        switch (mFormat) {
        /*
         * case OLD_FORMAT: { (new OldMapSaver()).save(mMap, mFilename); return;
         * }
         */

        case SIMPLE_FORMAT: {
            (new SimpleSaver()).save(mMap, mFilename);
            return;
        }

            /*
             * case XML_FORMAT: { (new XmlMapSaver()).save(mMap, mFilename);
             * return; }
             */
        }

        Utils.dump("Invalid map format: " + mFormat, Utils.ERROR);
        System.exit(1);
    }
}